package com.example.fund;

import java.util.ArrayList;
import java.util.List;

import com.example.fund.util.DBManager;

import android.app.Activity;

public class ActivityCollector 
{
	public static List<Activity> activities = new ArrayList<Activity>();
	
	public static void addActivity(Activity activity) 
	{
		activities.add(activity);
	}
	
	public static void removeActivity(Activity activity) 
	{
		activities.remove(activity);
		if(activities.size()==0)
		{
			DBManager.closeDB();
		}
	}
	
	public static void finishAll() 
	{
		for (Activity activity : activities) 
		{
			if (!activity.isFinishing()) 
			{
				activity.finish();
			}
		}
		DBManager.closeDB();
	}
}
